//
//  xqkct.m
//  PASystem
//
//  Created by michael on 16/8/24.
//  Copyright © 2016年 czd. All rights reserved.
//

#import "xqkct.h"
#import "kcTableViewCell.h"
@implementation xqkct
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    UIColor *myColor = [UIColor colorWithWhite:0.8 alpha:0.3];
self.backgroundColor = myColor;


          }
    return self;
}
- (void)setId:(NSString *)id{


//NSLog(@"11%@",id);
_id = id;
 [self initview];
[self request];
 
}
- (void)initview{
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(10, 10, KScreenWidth-20, (KScreenHeight-64-46-80)/3-20)];
view.backgroundColor= [UIColor whiteColor];

 UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0,0,KScreenWidth-20 , 20)];
    view1.backgroundColor = [UIColor whiteColor];
    UIView *viewcolor = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, view1.height)];
    viewcolor.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"图标3"]];
    [view1 addSubview:viewcolor];
     UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(viewcolor.right+20, viewcolor.top+5, 200, view1.height-5)];
          label.font = [UIFont systemFontOfSize:13];
label.textColor = [UIColor blueColor];
    label.text = @"考察信息 :";
    [view1 addSubview:label];
    
[view addSubview:view1];
_view = [[xmkcup alloc]initWithFrame:CGRectMake(0 , 20, KScreenWidth-20, (KScreenHeight-64-46-80)/3-20-20)];
_view.field = _id;
[view addSubview:_view];

[self addSubview:view];


 UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(10,view.bottom+10,KScreenWidth-20 , KScreenHeight-64-46-80-view.height-30)];
 view2.backgroundColor = [UIColor whiteColor];
  UIView *view11 = [[UIView alloc]initWithFrame:CGRectMake(0,0,KScreenWidth-20 , 20)];
    view11.backgroundColor = [UIColor whiteColor];
    UIView *viewcolor11 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, view11.height)];
    viewcolor11.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"图标3"]];
    [view11 addSubview:viewcolor11];
     UILabel *label11 = [[UILabel alloc]initWithFrame:CGRectMake(viewcolor11.right+20, viewcolor11.top+5, 200, view11.height-5)];
          label11.font = [UIFont systemFontOfSize:13];
label11.textColor = [UIColor blueColor];
    label11.text = @"成员列表 :";
    [view11 addSubview:label11];
    [view2 addSubview:view11];
    


_tableview = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableview.frame = CGRectMake(0, 20, KScreenWidth-20, view2.height-20);

_tableview.dataSource = self;
_tableview.delegate = self;
self.tableview.bounces = NO;
[view2 addSubview:_tableview];
    
    
 [self addSubview:view2];



}
- (void)request{
NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
    NSString * pwdId = [[NSUserDefaults standardUserDefaults]objectForKey:@"pwdId"];
    NSString * userHumber = [[NSUserDefaults standardUserDefaults]objectForKey:@"userHumber"];
    
 NSString *json =[NSString stringWithFormat: @"{'action':cyxxMch,'service':DXMService, 'userName':'%@','password':'%@', 'vaueJson':'{userid :%@,id:%@}'}",userId,pwdId,userHumber,_id];
     NSArray * array = @[@{@"arg0":json}];
    [HttpTools requestWithURL:BaseURL arrays:array method:Basemethod success:^(id JSON) {

    NSArray *updic = JSON[@"reason"];

       _dataArray = [NSMutableArray array];
       
for (NSDictionary *dic in updic) {
    kcmodel *model = [kcmodel mj_objectWithKeyValues:dic[@"attrs"]];
    [_dataArray addObject:model];
}
[_tableview reloadData];
//       NSLog(@"%@",_dataArray);

    } failure:^(NSError *error) {
        
    }];



}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  _dataArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

return 60;
}

#pragma mark UITableView dataScource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
 static NSString *CellIdentifier = @"Cell111111";  

    kcTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell==nil) {  
        cell=[[kcTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    kcmodel *model = _dataArray [indexPath.row];
    cell.model = model;
//cell.action = _action;
    return cell;
}

@end
